<?php
// +--------------------------------------------------------------------------
// | ISDCE [ 载攸道 先顺得常 ] <http://www.zaiyoudao.com>
// +--------------------------------------------------------------------------
// | Copyright © 2009-2017 载攸道 版权所有 <TEL:086-010-57209502>
// +--------------------------------------------------------------------------
// | Project: YiPHP [ 我会的仅仅是偷懒！ ] <http://www.yiphp.com>
// +--------------------------------------------------------------------------
// | Author: 牛很多戒很多不戒 <n@isdce.com> <http://juexue.wang>
// +--------------------------------------------------------------------------

/**
 * [ 后台模块 ]
 */
namespace Admin\Controller;
use Common\Controller\AdminController;

/**
 * 我的控制器
 */
class MyController extends AdminController{
	
	/**
	 * 修改信息
	 */
    public function Info(){

		$m_common_user = M('common_user');
			
		$map['id'] = getUID();
			
		if(IS_AJAX){
			
			action_log('admin_my_info_edit');//行为记录
		
			$data = I('');
			
			$result = $m_common_user->where($map)->save($data);
	
			//返回信息
			$info = $result?get_errcode(0):get_errcode(10000002);
			
			$this->ajaxReturn($info);
			
		}else{
			
			action_log('admin_my_info_view');//行为记录
			
			//页面配置
			$page = array(
				
				'title'=>'修改信息',
				'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
				'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
				'author'=>'YiPHP',
				'robots' => 'all',
			
			);
			
			$this->assign('page',$page);
		
			$data = $m_common_user->where($map)->find();
			
			$this->assign('data',$data);
			
			$this->display();
		}
		
		
	}
	
	/**
	 * 修改密码
	 */
    public function Password(){
		
		$m_common_user = M('common_user');
			
		$map['id'] = getUID();
		
		if(IS_AJAX){
			
			action_log('admin_my_password_edit');//行为记录
		
			$map['password'] = md5(I('param.oldpassword'));
			$data['password'] = md5(I('param.password'));
			
			$result = $m_common_user->where($map)->save($data);
	
			//返回信息
			$info = $result?get_errcode(0):get_errcode(10000003);
			
			$this->ajaxReturn($info);
			
		}else{
			
			action_log('admin_my_password_view');//行为记录
			
			//页面配置
			$page = array(
				
				'title'=>'修改密码',
				'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
				'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
				'author'=>'YiPHP',
				'robots' => 'all',
			
			);
			
			$this->assign('page',$page);
		
			$this->display();
		}
	}
	
	
}